<!--
 * @Author: your name
 * @Date: 2020-06-30 11:09:01
 * @LastEditTime: 2020-07-07 15:58:32
 * @LastEditors: Please set LastEditors
 * @Description: 加入购物车
 * @FilePath: \JKShopping\jkshopping\src\pages\home\components\goodsDetails\components\shopcar.vue
--> 
<template>
  <div class="shopcar">
    <van-goods-action safe-area-inset-bottom>
      <van-goods-action-icon icon="chat-o" text="客服" />
      <van-goods-action-icon to="/shoppingcart" icon="cart-o" text="购物车" :badge="badge" />
      <van-goods-action-icon icon="shop-o" text="店铺" />
      <van-goods-action-button type="danger" text="立即购买" @click="showsku" />
    </van-goods-action>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showsku: "", //sku弹窗
      badge: 0
    };
  },
  methods:{
    getBadge(list){
      let sum = 0
        sum += list
      return sum
    }
  }
  ,
  watch: {
    badge: {
      handler(newVal) {
        this.badge = this.getBadge(newVal)
      },
      immediate:true
    }
  },

  created() {
    this.$eventBus.$on("shopbadge", res2 => {
      this.badge = this.getBadge(res2)
    });
    this.$eventBus.$on("showsku", res => {
      this.showsku = res;
    });
  }
};
</script>

<style>
</style>